package com.liao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liao.bean.Param;
import com.liao.bean.result.Msg;
import com.liao.bean.result.PageResult;
import com.liao.dao.ParamDao;
import com.liao.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ParamServiceImpl implements ParamService {

    @Autowired
    private ParamDao paramDao;

    @Override
    public PageResult<Param> queryParamListByPage(Integer currentPage, Integer pageSize, String paramKey) throws Exception {
        PageHelper.startPage(currentPage,pageSize);
        //查询所有菜单
        List<Param> paramList = paramDao.selectParamListLikeParamName(paramKey);
        PageInfo<Param> pageInfo = new PageInfo<>(paramList);
        return new PageResult<>(0, Msg.PARAM_QUERY_SUCCESS,pageInfo.getTotal(),pageInfo.getList());
    }

    @Override
    public void addParam(Param param) throws Exception {
        paramDao.addParam(param);
    }

    @Override
    public void editParam(Param param) throws Exception {
        paramDao.updateParam(param);
    }

    @Override
    public void deleteParam(String paramId) throws Exception {
        paramDao.deleteParam(paramId);
    }


}
